<%- content_for :head do -%>
  <script type="text/javascript" charset="utf-8">
	labtofactureForm = new Subform('<%= escape_javascript(render(:partial => "labtofacture", :object => Labtofacture.new, :locals => {:index => "INDEX"})) %>',<%= @labour.labtofactures.length %>,'labtofactures');
	labtoparcelleForm = new Subform('<%= escape_javascript(render(:partial => "labtoparcelle", :object => Labtoparcelle.new, :locals => {:index => "INDEX"})) %>',<%= @labour.labtoparcelles.length %>,'labtoparcelles');
  </script>
<%- end -%>

<p>
  <%= link_to_function "Show/Hide Params", visual_effect(:toggle_blind, :params, :duration => "0.1") %>
</p>
<div id="params" style="display:none;">
  <%= debug params %>
</div>

<%= render :partial => "error_messages", :object => @labour, :locals => {:order => [:name, :labtoparcelles, :all]} %>

<% form_for @labour do |f| -%>

<fieldset>
  <legend>Traitement</legend>
	<table>
	<tr>
		<td>Nom : </td>
		<td><%= f.text_field :name, :size => 10 %></td>
	</tr>
	<tr>
		<td>Prestataire</td>
		<td><%= select("labour", "user_id", User.find(:all).collect{ |c| [ c.name, c.id] }) %></td>
	</tr>
	<tr>
		<td>Prix du passage</td>
		<td><%= f.text_field :cout_ha_passage, :size => 3 %> euros/Ha</td>
	</tr>
	<tr>
		<td>Categorie: </td>
		<td><%= select("labour", "category_id", Category.find_by_type("labour").collect{ |c| [ c.name, c.id] }) %></td>
	</tr>
	</table>
</fieldset>

<fieldset>
  <legend><%= @labour.labtoparcelles.length %> Pacelles</legend>
	<div id="labtoparcelles">
    <%= render :partial => 'labtoparcelle', :collection => @labour.labtoparcelles %>
  </div>
  <p><%= link_to_function "Ajouter une Parcelle", "labtoparcelleForm.add()" %></p>
</fieldset>

<fieldset>		
  <legend>Factures</legend>		
  <div class="yui-g">		
    <div class="yui-u first">		
      <div id="labtofactures">		
        <%= render :partial => 'labtofacture', :collection => @labour.labtofactures %>		
      </div>		
      <p><%= link_to_function "Ajouter une Facture", "labtofactureForm.add()" %></p>		
    </div>		
  </div>		
</fieldset>

<p>
<%= f.submit "Submit" %>
</p>
<% end -%>
